package com.itcast.mallapplet.controller.rider;

import com.itcast.applet.dto.*;
import com.itcast.applet.entity.Address;
import com.itcast.applet.entity.Order;
import com.itcast.applet.entity.Rider;
import com.itcast.applet.vo.RiderTaskVO;
import com.itcast.context.BaseContext;
import com.itcast.mallapplet.service.RiderService;
import com.itcast.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/rider")
@Slf4j
@Api(tags = "APP-骑手端")
public class RiderController {

    @Autowired
    private RiderService riderService;


    @PostMapping("/login")
    @ApiOperation("骑手登录")
    public Result<Rider> riderLogin(@RequestBody RiderLoginDTO riderLoginDTO) {
        log.info("骑手登录信息为:{}",riderLoginDTO);
        Rider rider = riderService.riderLogin(riderLoginDTO);
        return Result.success(rider);
    }

    @GetMapping("/query")
    @ApiOperation("骑手查看订单")
    public Result<RiderTaskVO[]> riderQuery(Long id) {
        log.info("骑手id为:{}",id);
        RiderTaskVO[] riderTaskVOS = riderService.riderQuery(id);
        return Result.success(riderTaskVOS);
    }


    @PostMapping("/amend")
    @ApiOperation("骑手经纬度修改")
    public Result riderAmend(@RequestBody RiderAmendDTO riderAmendDTO) {
        log.info("骑手经纬度信息为:{}",riderAmendDTO);
        riderService.riderAmend(riderAmendDTO);
        return Result.success();
    }


    @PostMapping("/order")
    @ApiOperation("骑手完成订单")
    public Result riderOrder(@RequestBody RiderOrderDTO riderOrderDTO) {
        log.info("骑手完成订单id为:{}",riderOrderDTO.getOrderId());
        riderService.riderOrder(riderOrderDTO);
        return Result.success();
    }










}
